<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="org.limp.mine.StringTool" %>
<%@ page import="jt.classic.system.utils.SystemTool" %>
<%@ page import="com.sinodata.ns.sv.ISupervisor" %>
<%@ page import="com.sinodata.ns.cell.JLBDInfo" %>
<%@ page import="com.sinodata.ns.cell.CellBDInfo" %>
<%
	ISupervisor sv = (ISupervisor)request.getAttribute("sv");
	
	String result = null;
	
	if (sv == null) {
	    result = "{success: false, errCode : -1}";
	} else {
		String bdids = "";
		
		String bdnames =  "";
		
		if(sv.ibd() != null && sv.ibd().icell() != null && !sv.ibd().icell().ibd().isEmpty()){
			for(int i=0; i < sv.ibd().icell().ibd().size(); i++){
				CellBDInfo cbi = (CellBDInfo)sv.ibd().icell().ibd().get(i);
				if(i < sv.ibd().icell().ibd().size() - 1){
					bdids += cbi.id();
					bdnames += cbi.iname();
				}else{
					bdids += cbi.id() + ",";
					bdnames += cbi.iname() + ",";
				}
			}
		}
		
		String deptName = sv.iuser().igroup().iname();
		
		result = "{success: true, data:{rid:'" + sv.id() + "', unit : '"+deptName+"', uname:'" + sv.iuser().iname() + "',numcode:'" +
	        sv.imobilecode() + "',nubdid:'" + (sv.ibd() != null ? sv.ibd().id() : "") + "',nubd:'" +
	        (sv.ibd() != null ? sv.ibd().iname() : "") + "',nugc : '"+(sv.ibd() != null ? sv.ibd().ibdname() : "")+"',nubditemid:'" +
	        (sv.icellbd() != null ? sv.icellbd().id() : "") + "',nubditem : '"+(sv.icellbd() != null ? sv.icellbd().iname() : "") + 
	        "', nubdid_:'" + ((sv.ibd() != null && sv.icellbd() != null) ? (sv.ibd().iname() + " : " + sv.icellbd().iname()) : "") +
	        "', uphone:'" + sv.iuser().iphone() + "', sex:'" + sv.iuser().isex() +
	        "', _rating:'" + sv.iuser().irating() +
	        "', rating:'" + sv.iuser().irating() +
	        "', nucellid : '"+bdids+"', nucell : '"+bdnames+"'}}";
	}
	
	request.setAttribute("result", result);

	SystemTool.returnJson(request, response);
%>